﻿@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@using Wantn.FIS.Enum;
@{
    ViewBag.Title = "试样信息";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
}
<div class="mvctool">
    <input id="txtBatch" type="text" placeholder="批次编码"   class="searchText" style="width:100px"/>
    @*<input id="txtRfid" type="text" placeholder="RFID芯片号"  class="searchText" style="width:140px" />*@
    <input id="txtStartCDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', maxDate: '#F{$dp.$D(\'txtEndCDate\')}' })"  type="text" class="condition-date" placeholder="样品生成时间起"/>
    <input id="txtEndCDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'txtStartCDate\')}' })"  type="text" class="condition-date" placeholder="样品生成时间止"/>
    <input id="txtStartDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', maxDate: '#F{$dp.$D(\'txtEndDate\')}' })"  type="text" class="condition-date" placeholder="样品称重时间起"/>
    <input id="txtEndDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'txtStartDate\')}' })"  type="text" class="condition-date" placeholder="样品称重时间止"/>
    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query, ref perm, "Query", true)
    @Html.ToolButton("btnExport", "fa fa-level-up", Resource.Export, ref perm, "Export", true)
</div>
<table id="List"></table>

<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<script type="text/javascript">
    $(function () {
        $('#List').datagrid({
            url: '@Url.Action("GetList")',
            width:SetGridWidthSub(10),
            methord: 'post',
            height: SetGridHeightSub(45),
            fitColumns: true,
            sortName: 'BATCH_CODE',
            sortOrder: 'desc',
            idField: 'BATCH_CODE',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            rownumbers: true,//行号
            onLoadSuccess: function(data) {
            },
            columns: [[
                { field: 'BATCH_CODE', title: '批次编码', width: 80, sortable: true },
                { field: 'MAKE_CODE', title: '制样类型',  sortable: true },
                { field: 'SAMPLE_CODE', title: '试样编码', width: 80, sortable: true },
                { field: 'MATERIEL_NAME', title: '物料', width: 60, sortable: true },
                { field: 'MINE_NAME', title: '类型', width: 40, sortable: true },
                { field: 'SUPPLIER_NAME', title: '供应商', width: 120, sortable: true },
                { field: 'TRANSPORT_NAME', title: '运输商', width: 120, sortable: true },
                { field: 'SAMPLE_TYPE_STR', title: '样品类型', width: 70, sortable: true },
                { field: 'COLLECT_CODE', title: '收样编码', width: 70, sortable: true },
                { field: 'CREATE_TIME', title: '样品生成时间', width: 120, sortable: true },
                { field: 'WEIGHT_USER_NAME', title: '制样员', width: 80, sortable: true },
                { field: 'WEIGHT_TIME', title: '样品称重时间', width: 80, sortable: true, hidden: true },
                { field: 'WEIGHT', title: '样品重量(G)', width: 80, sortable: true, hidden: true },
            ]]
        });



        if (@Html.FieldShow(ref perm,"IsShow")== 0) {
            $('#List').datagrid('hideColumn', 'MATERIEL_NAME');
            $('#List').datagrid('hideColumn', 'SUPPLIER_NAME');
            $('#List').datagrid('hideColumn', 'TRANSPORT_NAME');
            
        }
    });
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }
    function frameReturnByReload(flag) {
        if (flag)
            $("#List").datagrid('load');
        else
            $("#List").datagrid('reload');
    }
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    $(function () {
        $("#btnQuery").click(function () {
            $("#List").datagrid("load", {
                batch: $("#txtBatch").val(),
                rfid: '',
                startcdate: $("#txtStartCDate").val(),
                endcdate: $("#txtEndCDate").val(),
                startdate: $("#txtStartDate").val(),
                enddate: $("#txtEndDate").val(),
            });

        });

        $("#btnExport").click(function () {
            var condition = "batch=" + $("#txtBatch").val() +
                "&startcdate=" + $("#txtStartCDate").val() +
                "&endcdate=" + $("#txtEndCDate").val() +
                "&startdate=" + $("#txtStartDate").val() +
                "&enddate=" + $("#txtEndDate").val();
            $.post("@Url.Action("CheckExportData")?" + condition, function(data) {
                if (data.type == 1)
                {
                    window.location = "@Url.Action("Export")?" + condition;
                }
                else
                {
                    $.messageBox5s(Lang.Tip, data.message);
                }
            }, "json");
        });
    });
</script>
